//
// Created by zx208 on 2024/10/16.
//

#include "../SequenceList.h"

// 试写一算法，实现顺序表的就地逆置

Status Reverse_SL(SqList *L){
    ElemType temp;
    if(L->length < 2) return ERROR;
    for (int i = 0; i < L->length/2; ++i) {
        temp = L->elem[i];
        L->elem[i] = L->elem[L->length-i-1];
        L->elem[L->length-i-1] = temp;
    }
    return OK;
}

int main(void){
    SqList L;
    int a[] = {1,2,3,4,5,6};
    L.elem = a;
    L.length = sizeof a / sizeof( int);
    Reverse_SL(&L);
    for (int i = 0; i < L.length; ++i) {
        printf("%d ", L.elem[i]);
    }
    return 0;
}